define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'talent/index' + location.search,
                    add_url: 'talent/add',
                    edit_url: 'talent/edit',
                    del_url: 'talent/del',
                    multi_url: 'talent/multi',
                    import_url: 'talent/import',
                    table: 'talent',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                searchFormVisible:true,
                showToggle:false,
                showColumns:false,
                search:false,
                showExport:false,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'sex', title: __('Sex')},
                        {field: 'birthday', title: __('Birthday'), operate: 'LIKE'},
                        {field: 'jiguan', title: __('Jiguan'), operate: 'LIKE'},
                        {field: 'political', title: __('Political'), operate: 'LIKE'},
                        {field: 'nation', title: __('Nation'), operate: 'LIKE'},
                        {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'phone', title: __('Phone'), operate: 'LIKE'},
                        {field: 'email', title: __('Email'), operate: 'LIKE'},
                        {field: 'qualification', title: __('Qualification'), operate: 'LIKE'},
                        {field: 'major', title: __('Major'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'graduate', title: __('Graduate'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'graduate_date', title: __('Graduate_date'), operate: 'LIKE'},
                        {field: 'teacher_certificate_subject', title: __('Teacher_certificate_subject'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'teacher_certificate_stage', title: __('Teacher_certificate_stage'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: '', title: __('工作经历'), operate: false,
                            formatter: function (value,row,index) {
                                return '<a href="talent/experience/ids/'+row.id+'" data-area=["75%","75%"] class="btn btn-success btn-xs btn-dialog" title="'+row.name+'-工作经历">工作经历</a>';
                            }
                        },
                        {field: 'idcard_zheng', title: __('Idcard_zheng'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'idcard_fan', title: __('Idcard_fan'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'graduate_zhengshu', title: __('Graduate_zhengshu'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'avatar', title: __('Avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'degree_zhengshu', title: __('Degree_zhengshu'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'qualification_zhengshu', title: __('Qualification_zhengshu'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'degree_report', title: __('Degree_report'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'teacher_zhengshu', title: __('Teacher_zhengshu'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'zige_teacher_zhengshu', title: __('Zige_teacher_zhengshu'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'crime_zhengming', title: __('Crime_zhengming'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'create_id', title: __('Create_id')},
                        {field: 'create_time', title: __('创建日期'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
